package com.tanhua.sso.controller;

import com.tanhua.sso.service.LoginService;
import com.tanhua.sso.vo.ErrorResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @title: LoginController
 * @Author TGE
 * @Date: 2021/5/9 11:29
 * @Version 1.0
 */
@Slf4j
@RequestMapping("/user")
@RestController
public class LoginController {
    @Autowired
    private LoginService loginService;
    /**
     * 登录第二步---验证码校验
     * @param pram
     * @return
     */
    @PostMapping("/loginVerification")
    public ResponseEntity<Object> login(@RequestBody Map<String,String> pram){
        Map<String,Boolean> result = null;
        try {
            result = loginService.login(pram);
            if (null!=result){

                return ResponseEntity.ok().body(result);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body( ErrorResult.builder().errCode("000002").errMessage("验证码错误！").build());
    }
}
